<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<%
	String path = request.getContextPath();
%>
<title>所有签约查询(服务器)</title>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/btn_class.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/style.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/ext-patch.css" />

<script type="text/javascript"
	src="<%=path%>/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/extjs/ext-all.js"></script>

<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/lovcombo-1.0/lovcombo.css" />
<script type="text/javascript" src="<%=path%>/extjs/lovcombo-1.0/lovcombo.js"></script>

	<script type="text/javascript" src="<%=path%>/js/datepicker/WdatePicker.js" defer="defer"></script>
	<script type="text/javascript" src="<%=path%>/public/public.js" defer="defer"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
	<div id="west-div" style="width: 100%; height: 100%;"></div>
	<div id="center-div"></div>
</body>
<script type="text/javascript">
	Ext.BLANK_IMAGE_URL = "<%=path%>/extjs/resources/images/default/s.gif";

	Ext.onReady(function() {
				Ext.QuickTips.init();
				
				// shorthand
				var Tree_op = Ext.tree;
				var loader_op = new Tree_op.TreeLoader({
					dataUrl : 'office!buildOfficeTree.do'
				});
				loader_op.on("beforeload", function(treeLoader, node) {
					//loader_op.baseParams.fcode = Ext.get("r_id").dom.value;//角色id
					//loader.baseParams.fcode  = node.attributes.fcode;
				}, this);

				loader_op.processResponse = function(response, node, callback) {
					var json1 = response.responseText;
					
					try {
						var json = eval("(" + json1 + ")");
						node.beginUpdate();
						//从json中取得json数组
						var o = json["key"];
						for ( var i = 0, len = o.length; i < len; i++) {
							var n = this.createNode(o[i]);
							if (n) {
								node.appendChild(n);
							}
						}
						node.endUpdate();
						if (typeof callback == "function") {
							callback(this, node);
						}
					} catch (e) {
						this.handleFailure(response);
					}
				};

				var tree_op = new Tree_op.TreePanel({
					region : 'center',
					id : 'west-panel',
					el : 'west-div',
					width : 280,
					//	title : '所属区县',
					useArrows : true,
					autoScroll : true,
					animate : true,
					enableDD : true,
					containerScroll : true,
					rootVisible : false, //树根不可见
					loader : loader_op
				});
				
				//单击事件
				tree_op.on('click', function(node) {
						contentpanel.setTitle("当前机构--><font color=blue>" + node.text + "</font>");
						Ext.get('foffice_flag').dom.value = node.id;
						// ds_user.removeAll();
						ds_user.on('beforeload', function(store) {
							this.baseParams = {
									'limit' : 50,
									'foffice' : node.id
								};
						});
						ds_user.load({
							params : {
								start : 0
							}
						});
					
				}, tree_op);
				
				/*
				//checkBox勾选事件
				tree_op.on('checkchange', function(node, checked) {
					node.expand();
					node.attributes.checked = checked;
					node.eachChild(function(child) {
						child.ui.toggleCheck(checked);
						child.attributes.checked = checked;
						child.fireEvent('checkchange', child, checked);
					});
					
					var checkedNodes = tree_op.getChecked();
					  var codeStr = "";
					
					  for(i=0;i<checkedNodes.length;i++) {
					      var checkeNode = checkedNodes[i];
					      codeStr = "'" + checkeNode.attributes.id + "'," + codeStr;
					  }
					 
					Ext.get("foffice_id").dom.value = codeStr+"'-100'";
					
				}, tree_op);
                */
                
				// set the root node
				var root_op = new Tree_op.AsyncTreeNode({
					text : '所有栏目',
					draggable : false,
					id : '-1',
					fid : '-1',
					ftype : '-1'
				});
				tree_op.setRootNode(root_op);

				
	var Jthtwb = Ext.data.Record.create([ {
		name : 'fpid',
		mapping : 'fpid',
		type : 'string'
	}, {
		name : 'fname',
		mapping : 'fname',
		type : 'string'
	}, {
		name : 'fdesc',
		mapping : 'fdesc',
		type : 'string'
	}, {
		name : 'fcdate',
		mapping : 'fcdate',
		type : 'string'
	}, {
		name : 'fldate',
		mapping : 'fldate',
		type : 'string'
	}, {
		name : 'loginName',
		mapping : 'loginName',
		type : 'string'
	}, {
		name : 'password',
		mapping : 'password',
		type : 'string'
	}, {
		name : 'fphone',
		mapping : 'fphone',
		type : 'string'
	}, {
					name : 'fstate',
					mapping : 'fstate',
					type : 'string'
				}, {
					name : 'fsex',
					mapping : 'fsex',
					type : 'string'
				}, {
					name : 'fphone1',
					mapping : 'fphone1',
					type : 'string'
				}, {
					name : 'fphone2',
					mapping : 'fphone3',
					type : 'string'
				}, {
					name : 'flis',
					mapping : 'flis',
					type : 'string'
				}, {
					name : 'fxyj',
					mapping : 'fxyj',
					type : 'string'
				}, {
					name : 'fyytx',
					mapping : 'fyytx',
					type : 'string'
				}, {
					name : 'fdate',
					mapping : 'fdate',
					type : 'string'
				}, {
					name : 'fsign_date',
					mapping : 'fsign_date',
					type : 'string'
				}, {
					name : 'fexception_low',
					mapping : 'fexception_low',
					type : 'string'
				}, {
					name : 'fexception_high',
					mapping : 'fexception_high',
					type : 'string'
				}, {
					name : 'fgz_exception',
					mapping : 'fgz_exception',
					type : 'string'
				}, {
					name : 'fphone3',
					mapping : 'fphone3',
					type : 'string'
				}, {
					name : 'fssy_high',
					mapping : 'fssy_high',
					type : 'string'
				}, {
					name : 'fssy_low',
					mapping : 'fssy_low',
					type : 'string'
				}, {
					name : 'fszy_high',
					mapping : 'fszy_high',
					type : 'string'
				}, {
					name : 'fszy_low',
					mapping : 'fszy_low',
					type : 'string'
				}, {
					name : 'fxl_high',
					mapping : 'fxl_high',
					type : 'string'
				}, {
					name : 'fxl_low',
					mapping : 'fxl_low',
					type : 'string'
				}, {
					name : 'fxt_high',
					mapping : 'fxt_high',
					type : 'string'
				}, {
					name : 'fxt_low',
					mapping : 'fxt_low',
					type : 'string'
				} ]);

	//用户列表
	var ds_user = new Ext.data.Store({
		reader : new Ext.data.JsonReader({
			totalProperty : 'totalProperty',
			root : 'root'
		}, Jthtwb),
		idProperty : 'threadid',
		remoteSort : true,
		url : 'user!queryUserList.do'
	});
	

	//定义勾选框，不需要可不必定义
	var sm_user = new Ext.grid.CheckboxSelectionModel({
		singleSelect : false
	});

	//定义列
	var colM_user = new Ext.grid.ColumnModel([ sm_user, new Ext.grid.RowNumberer(),//增加自动编号，不需要可不必定义
	    {
			header : '姓名',
			dataIndex : 'fname',
			width : 120,
			renderer : function(value) {
					if (value == "null") {
						return "";
					} else {
						return value;
					}
				}
		}, {
			header : '手机号码',
			dataIndex : 'fphone',
			width : 120,
			renderer : function(value) {
					if (value == "null") {
						return "";
					} else {
						return value;
					}
				}
		}, {
			header : '登录名',
			dataIndex : 'loginName',
			width : 120,
			sortable : false
		}]);

	//生成表格
	var grid_user = new Ext.grid.GridPanel({
		region : 'center',
		height : 350,
		autoWidth : true,
		stripeRows : true,
		listeners : {
			'rowclick' : function(grid, row) { //双击打开
				var record = grid.getSelectionModel().getSelected();
				if (record) {
						// ds_user.removeAll();
						ds.on('beforeload', function(store) {
							this.baseParams = {
									'limit' : 50,
									'floginname' : record.data.loginName,
									'foffice' : Ext.get('foffice_flag').dom.value
								};
						});
						ds.load({
							params : {
								start : 0
							}
						});
				}
			}
		},
		cm : colM_user,
		ds : ds_user,
		sm : sm_user,
		enableHdMenu : false
	});
	
	var btn_refresh = new Ext.Button({
		text : '刷新',
		iconCls : 'sy-refresh',
		handler : function() {
			ds_user.removeAll();
			ds_user.reload();
		}
	});
	
	
	
	var ds = new Ext.data.Store({
					reader : new Ext.data.JsonReader({
						totalProperty : 'totalProperty',
						root : 'root'
					}, Jthtwb),
					idProperty : 'threadid',
					remoteSort : true,
					url : 'patient!queryPatientSigned.do'
				});

				ds.load( {
					params : {
						start : 0,
						limit : 50,
						fstate : '1',
						fkeywords : '',
						foffice : '-100',
						floginname : '-100',
					//	fbtime : '',
						fetime : ''
					}
				});


				//定义勾选框，不需要可不必定义
				var sm = new Ext.grid.CheckboxSelectionModel({
					singleSelect : true //单选
				});
				
				//定义列
				var colM = new Ext.grid.ColumnModel([ sm, // new Ext.grid.RowNumberer(),//增加自动编号，不需要可不必定义
				    {
						header : '姓名',
						dataIndex : 'fname',
						width : 80,
						sortable : false
					}, {
						header : '性别',
						dataIndex : 'fsex',
						width : 60,
						renderer : function(value) {
								if (value == "1" || value == "男") {
									return "男";
								} else if (value == "2" || value == "女") {
									return "女";
								} else {
									return "";
								}
							}
					},{
						header : '手机号码',
						dataIndex : 'fphone1',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					},{
						header : '身份证号',
						dataIndex : 'fsfzh',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					},{
						header : '医保卡号',
						dataIndex : 'fybkh',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					}, {
						header : '血压监测',
						dataIndex : 'fxyjc',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '血糖监测',
						dataIndex : 'fxtjc',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '血脂',
						dataIndex : 'fxzjc',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '血尿酸',
						dataIndex : 'fxnsjc',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '血肌酐',
						dataIndex : 'fxjgjc',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '血氧饱和度',
						dataIndex : 'fxybhdjc',
						width : 100,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '心电',
						dataIndex : 'fxdjc',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					}, {
						header : '位置服务',
						dataIndex : 'fwzfw',
						width : 80,
						renderer : function(value) {
								if (value == "1" || value == "on") {
									return "<img src='<%=path%>/ext-2.2/icons/tick.png' border=0>";
								} else {
									return "<img src='<%=path%>/ext-2.2/icons/cross.png' border=0>";
								}
							}
					} ]);

				//生成表格
				var grid = new Ext.grid.GridPanel({
					closable : false,
					region : 'center',
					layout:'fit',
					height : 350,
					autoWidth : true,
					stripeRows : true,
					//title : '角色列表',
					cm : colM,
					ds : ds,
					sm : sm,
					listeners : {
						'rowclick' : function(grid, row) { //双击打开
							var record = grid.getSelectionModel().getSelected();
							if (record) {
							    window.frames["ifr_xyjc"].location.href = "app_xyjc.jsp?fphone=" + record.data.fphone1;   
								window.frames["ifr_xtjc"].location.href = "app_xtjc.jsp?fphone=" + record.data.fphone1;
								window.frames["ifr_xyjc"].location.href = "app_xyjc.jsp?fphone=" + record.data.fphone1;
								window.frames["ifr_xyjc"].location.href = "app_xyjc.jsp?fphone=" + record.data.fphone1;
								window.frames["ifr_xyjc"].location.href = "app_xyjc.jsp?fphone=" + record.data.fphone1;
								window.frames["ifr_jtzx"].location.href = "app_jtzx.jsp?fphone=" + record.data.fphone1;
								
								
							    // Ext.getCmp('xyjc_id').load({url:"app_xyjc.jsp?fphone='15105210211'",scripts:true});
								// sign_mod_fun(record.data.fpid, record.data.fname, record.data.fsex, record.data.fadd_detail, record.data.fphone1, record.data.fphone2);
							}
						}
					},
					bbar : new Ext.PagingToolbar({
				        pageSize: 50,
				        store: ds,
				        displayInfo: true,
				        displayMsg: '共 {2} 条记录',
				        emptyMsg: "没有记录"
				    })
				});
	
     var panel = new Ext.Panel({
			    	region: "center",
					layout:'fit',
					border : true,
					margins:'0 5 0 0',
					tbar : [ '-' ],
					items : [ grid ]
				});
				
				
				var btn_refresh_office = new Ext.Button({
					text : '刷新',
					iconCls : 'sy-refresh',
					handler : function(btn) {
						tree_op.root.reload();
					}
				});
				
				var panelmenu = new Ext.Panel({
					region: "west",
					split:true,
		            minSize: 105,
		            maxSize: 400,
		            collapsible: true,
		            collapsed: false, //展开或关闭
		            margins:'0 0 0 0',
		            layout:'fit',
		            layoutConfig:{
		                animate:true
		            },
		            tbar : [ '->', btn_refresh_office ],
					items :[tree_op],
					width:280
			   });
			   
			   var rightpanel = new Ext.Panel({
					region: "west",
					split:true,
		            minSize: 105,
		            maxSize: 400,
		            collapsible: true,
		            collapsed: false, //展开或关闭
		            margins:'0 0 0 0',
		            layout:'fit',
		            layoutConfig:{
		                animate:true
		            },
		            tbar : [ btn_refresh , {
						xtype : 'hidden',
						id : 'foffice_flag',
						name : 'foffice_flag'
					}],
					items : [ grid_user ],
					width:280
			   });
			   
			   var contentpanel = new Ext.Panel({
					region: "center",
					layout:'border',
		            layoutConfig:{
		                animate:true
		            },
		            title : '当前机构',
		            tbar : [ '->' ],
					items :[rightpanel, panel],
					width:380
			   });
				
				
				/************************************* 所属区县树 结束 ********************************************************/
				var viewport = new Ext.Viewport({
					layout : 'border',
					items : [ panelmenu, contentpanel ]
				});
				
				
			});
</script>


</html>